package com.db.dao;

import java.util.List;

import com.db.bean.Work;
import com.db.bean.WorkUser;

import util.BaseDAO;

/**
* @author 作者:秋哲    E-mail:2810201146@qq.com:
* @version 创建时间：2020年5月21日 下午10:09:55
* @description: 
*/
public class WorkUserDAOImpl extends BaseDAO<WorkUser> implements WorkUserDAO {
	@Override
	public int updateWorkUser(WorkUser WorkUser_obj) {
		String sql = "update work_workuser set `state`=?,`user_id`=?,`work_id`=? where id = ?";
		int update = update(sql, WorkUser_obj.getState(),WorkUser_obj.getUser_id(),WorkUser_obj.getWork_id(),WorkUser_obj.getId());
		return update;
	}
	@Override
	public List<WorkUser> getAll(int work_id, int president_id) {
		String sql = "SELECT * from work_workuser where user_id in (select id from user_user where user_user.president_id = ?) and work_id = ?";
		List<WorkUser> queryList = queryList(sql, president_id,work_id);
		return queryList;
	}
	@Override
	public int allUserPass(int work_id, int president_id) {
		String sql = "update work_workuser set `state`='True' where user_id in (select id from user_user where user_user.president_id = ?) and work_id = ? and state='None'";
		int update = update(sql,president_id,work_id);
		return update;
	}

}
